package com.dhcc.core.modules.common.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhcc.core.framework.base.controller.BaseController;
import com.dhcc.core.framework.result.node.ZTreeNode;
import com.dhcc.core.modules.system.cache.dept.DeptCache;
import com.dhcc.core.modules.system.cache.group.GroupCache;
import com.dhcc.core.modules.system.cache.position.PositionCache;
import com.dhcc.core.modules.system.cache.resource.ResourceCache;
import com.dhcc.core.modules.system.cache.role.RoleCache;
import com.dhcc.core.modules.system.cache.user.UserCache;

/**
 * 树集合
 *
 * @ClassName: TreeController
 * @Description: TODO
 * @author cyf  
 * @date 2018-09-10 14:39:55
 */
@Controller
@RequestMapping("${sys.backendPath}/tree")
public class TreeController  extends BaseController {

    /**
     * 获取部门的tree列表
     */
    @RequestMapping(value = "/dept")
    @ResponseBody
    public List<ZTreeNode> dept() {
        return DeptCache.me().getDeptTree();
    }
    /**
     * 获取部门用户树(不包含admin)
     */
    @RequestMapping(value = "/user")
    @ResponseBody
    public List<ZTreeNode> user() {
        return UserCache.me().getUserTree();
    }
    /**
     * 获取部门用户树--部分管理界面用(包含admin)
     */
    @RequestMapping(value = "/user/admin")
    @ResponseBody
    public List<ZTreeNode> userAdmin() {
        return UserCache.me().getUserTreeAdmin();
    }
    /**
     * 获取公共群组的tree列表
     */
    @RequestMapping(value = "/group/public")
    @ResponseBody
    public List<ZTreeNode> groupPublic() {
        return GroupCache.me().getPublicGroupTree();
    }
    /**
     * 获取个人群组的tree列表
     */
    @RequestMapping(value = "/group/personal")
    @ResponseBody
    public List<ZTreeNode> personalGroupTree() {
        return GroupCache.me().getPersonalGroupTree(getLoginUserId());
    }
    /**
     * 获取角色列表--不包含everyone
     */
    @RequestMapping(value = "/role")
    @ResponseBody
    public List<ZTreeNode> role() {
        return RoleCache.me().getRoleTree();
    }
    /**
     * 获取角色列表--管理界面用(包含everyone)
     */
    @RequestMapping(value = "/role/everyone")
    @ResponseBody
    public List<ZTreeNode> roleEveryone() {
        return RoleCache.me().getRoleTreeEveryone();
    }
    /**
     * 获取职务树
     */
    @RequestMapping(value = "/position")
    @ResponseBody
    public List<ZTreeNode> position() {
        return PositionCache.me().getPositionTree();
    }
    /**
     * 获取后台资源列表(所有)
     */
    @RequestMapping(value = "/resource/backend")
    @ResponseBody
    public List<ZTreeNode> resourceBackend() {
        return ResourceCache.me().getBackendResourceTree();
    }
    /**
     * 获取前台资源列表(所有)
     */
    @RequestMapping(value = "/resource/front")
    @ResponseBody
    public List<ZTreeNode> resourceFront() {
        return ResourceCache.me().getFrontdResourceTree();
    }
    /**
     * 获取接口资源列表(所有)
     */
    @RequestMapping(value = "/resource/api")
    @ResponseBody
    public List<ZTreeNode> resourceApi() {
        return ResourceCache.me().getApiResourceTree();
    }

}
